<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/taglibs.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
  <head>
    <title>商户注册</title>
    <%@ include file="../../common/meta.jsp"%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">


    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
    <link href="<%=basePath%>css/bootstrap-responsive.min.css" rel="stylesheet" />
    <link href="<%=basePath%>css/loadmask.css" rel="stylesheet" />
    <link href="<%=basePath%>css/style_buyer.css" rel="stylesheet" />
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <link href="<%= basePath %>images/upload/uploadify.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<%=basePath%>js/jquery.uploadify.min.js"></script>

  </head>
  <style>
	hr {
	    margin-top:1px;
	    border-bottom: 1px solid #1BBC9B;
	}
  </style>
  <body>
 <ul class="loginAboutDoor container widthNine">
        <li><a href="" target="_blank">关于我们</a></li>
        <li><a href="" target="_blank">平台价值</a></li>
        <li><a href="" target="_blank">联系我们</a></li>
        <li>客服电话：021-61535881</li>
    </ul>
    <div class="topImg_2 container boxPadd" style="margin-top: -10px;">
        <img src="<%=basePath%>image/logo_stat.png" class="changH" />
        <span>欢迎使用</span>
    </div>

    <div class="container-fluid loginBox fristLoginBox" style="height:900px">
        <div class="container">
            <img class="loginImg" src="<%=basePath%>image/down_app_img2.png" height="500" />
            <div class="loginList widthA" style="height:850px;margin-top:4px;">
<form action="" class="form-horizontal" id="loginForm" method="post" role="form">                    <ul>
                        <!-- <li>商 户 号 ：<input type="text" id="company_no" placeholder="您的商户号" name="company_no" class="required" data-msg-required="请输入商户号" maxlength="7" /></li> -->
                        <li>公司名称 ：<input type="text" id="company_name" placeholder="您的公司名称" name="company_name" class="required" data-msg-required="请输入公司名称" maxlength="60" /></li>
                        <li>
         					<table>
         						<tr>
         							<td>公司角色 ：</td>
         							<td>
	         							<select class="form-control" id="ext3" name="ext3">
								         <option value="1" selected>批发商</option>
								         <option value="2">采购商</option>
								         <option value="3">其他</option>
								      </select>
         							</td>
         						</tr>
         					</table>
                        </li>
                        <li>公司主营产品 ：<input type="text" id="ext2" placeholder="公司主营产品" name="ext2" class="required" data-msg-required="请输入公司主营产品" maxlength="60" /></li>
                        <li>公司地址 ：<input type="text" id="company_addres" placeholder="您的公司地址" name="company_addres" class="required" data-msg-required="请输入公司地址" maxlength="60" /></li>
                        <li>公司电话 ：<input type="text" id="company_tel" placeholder="您的公司电话" name="company_tel" class="required" data-msg-required="请输入公司电话" maxlength="60" /></li>
                        <li>公司联系人 ：<input type="text" id="company_linkman" placeholder="您的公司联系人" name="company_linkman" class="required" data-msg-required="请输入公司联系人" maxlength="60" /></li>
                        <li>登录账号：<input type="text" placeholder="建议使用英文或者数字" id="user_no" name="user_no" class="required" data-msg-required="请输入登录帐号"  maxlength="20"/></li>
                        <!--
                        <li>用户名：<input type="text" placeholder="用户名" id="user_name" name="user_name" class="required" data-msg-required="请输入用户名"  maxlength="20"/></li>
                         -->
                        <li>
                            验 证 码 ：<input type="text" class="ipt_yan required" name="checkcode" id="checkcode" placeholder="输入验证码" data-msg-required="请输入验证码" />
                            <img id="imgCheck" class="floatr" height="34" src="<%=basePath %>Image" onClick="this.src = '<%=basePath %>Image?_r='+(new Date().valueOf())" alt="点击切换" style="margin:0;" />
                         </li>
                        <li>
                            设置密码：
                            <input type="text" autocomplete="off" style="display:none;" />
                            <input type="password" autocomplete="off" style="display:none;" />
                            <input type="password" placeholder="登录密码" name="password" id="password" class="required" data-msg-required="请输入登录密码" />
                        </li>
                        <li>
                            确认密码：
                            <input type="text" autocomplete="off" style="display:none;" />
                            <input type="password" autocomplete="off" style="display:none;" />
                            <input type="password" placeholder="登录密码" name="confirmPwd" class="required" equalto="#password" data-msg-required="请再次输入密码" autocomplete="off" data-msg-equalto="两次输入密码不一致" />
                        </li>
                        <li class="positiveRe"style="margin-bottom:20px;">
                            <input type="hidden" name="phone" value="" id="hiddenPhone" />
                            营业执照：<input type="text" disabled="disabled" placeholder="批发商需要营业执照，采购商不需要" class="required" id="imgpath" name="imgpath" style="text-indent:10px;font-size:12px;" />
                            <input type="hidden" placeholder="" class="required" id="img" name="img" style="text-indent:10px;font-size:12px;" />
 <button class="btn_yanzhengma iptRadis4" data-target="#myModal" data-toggle="modal" style="border:1px solid #c4c4c4;height:34px;" type="button" id="sendtupian">上传</button>
                        </li>
                        <!-- <li>姓名：<input type="text" placeholder="输入姓名" name="user_name" id="user_name" class="required" data-msg-required="请输入姓名" /></li> -->
                    </ul>
                    <p class="margin_l_20 positiveRe" style="margin-bottom:15px;"><input type="checkbox" name="checkbox" id="cb_agree" class="required" data-msg-required="请勾选平台服务协议" />我已阅读并同意<a href="javascript:showAgreementInfo();">《平台服务协议》</a></p>
                    <input class="btn btn-danger btn_login" id="zc" name="zc" value="注  册" type="submit" />
                    <p class="toFirstLogin"><a href="<%=basePath%>login" class="btn btn_login btn_firstLogin">登录</a></p>
</form>            </div>
        </div>
    </div>

    <div class="footer loginFooter">

        <div class="container">
            <p class="floatl" style="margin:20px 50px 0 230px;">
                <img src="<%=basePath%>image/piao_code.png" width="80" style=" border:4px solid #fff;vertical-align:bottom;" />
                <br />扫一扫关注微信
            </p>
                <p class="floatl" style="text-align:left;margin:0 0 0 0;padding:5px 0 10px 60px;border-left:1px dashed #ccc;">
                    <span style="font-size:16.5px;">立寻信息技术（上海）有限公司</span><br />
                    企业地址：上海市，闵行区，老沪闵路1317号2楼202-203室<br />
                   电话：021-61535880&nbsp;|&nbsp;021-61535881<br />
                    Copyright © 2015 www.lx361.com All Rights Reserved<br />

                </p>
        </div>

    </div>
    <iframe id="file_upload_return" hidden="true" name="file_upload_return"></iframe> <!-- 提交表单处理iframe框架 -->

    <!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
   aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
      <form action="" class="form-horizontal form-bordered form-row-strippe" id="form2" name="form2"  target="file_upload_return" enctype="multipart/form-data" method="post" >
      <div class="panel panel-primary" id="bsDiv">
         <div class="panel-body" id="bsDiv" class="panel-collapse collapse in">
	          <div class="form-group">
	              <label class="control-label col-md-5">文件上传：</label>
	              <div class="col-md-7">
 						<input type="file" name="file_name" id="file_name" onchange="fileCheck()"/>
 						<input type="hidden" name="filename" id="filename"/>
						<input type="button" id="buttonupload" onclick="fileUploadFun()" value="开始上传">
						<input type="button" id="buttonqxupload" onclick="fileUploadCancel()" value="取消上传">
	              </div>
	          </div>
	  </div>
	  </div>
	   </form>
      </div>
</div>
</div>
    <style>
        .loginBox .loginList ul li {
            margin-bottom:15px;
            position: relative;
        }

            .loginBox .loginList ul li .help-block {
                position: absolute;
                bottom: -16px;
                bottom: -24px\9;
                left: 10px;
                font-size: 11px;
                margin: 0;
                color: #f00;
                font-weight:normal;
            }
    </style>

    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "http://hm.baidu.com/hm.js?a28cb605eb4fb009f83127e6a7445084";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


    <script src="<%=basePath%>script/knockout-3.4.0.js"></script>
    <script src="<%=basePath%>script/jquery-1.9.1.js"></script>
    <script src="<%=basePath%>script/jquery.validate.js"></script>
    <script src="<%=basePath%>script/bootstrap/js/bootstrap.min.js"></script>
    <script src="<%=basePath%>script/bootstrap/js/bootbox.min.js"></script>
    <script src="<%=basePath%>script/ajaxHelpers.js"></script>
    <script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
    <script src="<%=basePath%>/js/respond.js"></script>
    <script src="<%=basePath%>/js/html5.js"></script>
    <script src="<%=basePath%>js/toastr/toastr.js"></script>
    <script src="<%=basePath%>js/bootbox.js"></script>
    <script src="<%= basePath %>js/tableSortTool.js" ></script>

    <script src="<%=basePath%>script/jquery.loadmask.js"></script>
    <script src="<%=basePath%>script/controls.js"></script>
    <script src="<%=basePath%>script/validata.js"></script>
    <script src="<%=basePath%>script/IdCard.js"></script>
    <script src="<%=basePath%>script/ProvinceCityCounty.js"></script>
    <script src="<%=basePath%>js/my-jquery-curd.js"></script>
    <script src="<%= basePath %>js/calendar.js" ></script>
    <script type='text/javascript'>(function () { document.getElementById('___szfw_logo___').oncontextmenu = function () { return false; } })();</script>
    <script type="text/javascript">
    $("#file_upload_return").load(function(){//获取iframe中的内容
    	var body = $(window.frames['file_upload_return'].document.body);
    	alert(body[0].textContent);
    	$("#myModal").modal("hide");
    	$("#imgpath").val($("#filename").val());
    	$("#img").val($("#filename").val());
    	});
    function fileUploadCancel(){
    	$("#myModal").modal("hide");
    }
//新增保存数据
function add() {
	$("#zc").attr("disabled", true);
	var url = "<%=basePath%>t_company_user/saveT_company_and_user?time="+Math.random();
	var postData = $("#loginForm").serializeArray();
    $.post(url, postData, function (data) {
    	//var data = $.parseJSON(data);
        if (data.result=="success") {
            //保存成功  1.关闭弹出层，
          	//showSuccessTips("恭喜保存成功!", "提示");
             alert("注册成功，等待审核！");
        	 //window.location.href = "<%=basePath%>/";
        }
        else {
            $("#zc").removeAttr("disabled");
            //alert("注册失败！");
            alert(data.info);
            //showErrorTips("保存数据失败!", "错误信息：");
        	return false;
        }
    }).error(function () {
        $("#zc").removeAttr("disabled");
    	//showErrorTips("注册失败!", "错误信息：");
    });
}

//账号只能是字母和数字组成
jQuery.validator.addMethod("checkUn", function(value, element){
	return this.optional(element) ||/^[a-zA-Z0-9]+$/.test(value);
}, "<font color='red'>账号只能包括英文字母和数字！</font>");

//初始化页面及校验
$().ready(function(){
	//uploadify();
	//2、校验脚本初始化，start check
	$("#loginForm").validate({
		submitHandler:function(form){
            //$(form).mask('正在注册，请稍后...');
			add();
	    },
		rules: {
			company_name: {
			    required: true,
			    maxlength: 128
    		},
			company_addres: {
			    required: true,
			    maxlength: 128
    		},
			company_tel: {
			    required: true,
			    maxlength: 128
    		},
			company_linkman: {
			    required: true,
			    maxlength: 128
    		},
    		user_no: {
			    required: true,
			    maxlength: 20,
			    checkUn: true
    		},
    		password:{
    			required: true
    		}

	    }, //end rules;
	    messages: {
			company_name: {
				required:"<font color='red'>公司名称必输！</font>",
			    maxlength: "<font color='red'>公司名称最大支持128位,输入的数据已经超过最大长度！</font>"
    		},
			company_addres: {
				required:"<font color='red'>公司地址必输！</font>",
			    maxlength: "<font color='red'>公司地址最大支持128位,输入的数据已经超过最大长度！</font>"
    		},
			company_tel: {
				required:"<font color='red'>公司电话必输！</font>",
			    maxlength: "<font color='red'>电话最大支持128位,输入的数据已经超过最大长度！</font>"
    		},
			company_linkman: {
				required:"<font color='red'>公司联系人必输！</font>",
			    maxlength: "<font color='red'>联系人最大支持128位,输入的数据已经超过最大长度！</font>"
    		},
			img: {
			    maxlength: "<font color='red'>图片最大支持512位,输入的数据已经超过最大长度！</font>"
    		},
    		user_no:{
    			required:"<font color='red'>登录账号必输！</font>",
    			 maxlength: "<font color='red'>登录账号最大支持20位,输入的数据已经超过最大长度！</font>"
    		}
	   } //end message;
   	}); //end validate;
}) //end funciton read;
function fileUploadFun(){
	var url = "<%=basePath%>t_company_user/reg_fileupload?t=1&time="+Math.random();
	form2.action =  url;
	form2.submit();
}
function fileCheck(){
	$("#filename").val($("#file_name").val());
}
</script>
  </body>
</html>